<%--
  Created by IntelliJ IDEA.
  User: 范军建
  Date: 2022/4/22
  Time: 21:12
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<%
    String path = request.getContextPath();
%>
<body background="image/9103.jpg" style=" background-size: 1700px 1000px">
<script src="js/jquery-3.2.1.min.js"></script>
<script type="text/javascript">

    function fun1() {
        var pass1 = $("#pass1").val();
        var pass2 = $("#pass2").val();
        var username = $("#username").val();
        alert(username)
        $.ajax({
            url: "success",
            type: "get",
            data: {
                pass1: pass1,
                pass2: pass2,
                username: username
            },
            dataType: "text",

            success: function (data) {
                alert(data)

                if (data == 1) {
                    var path = document.getElementById("path").value;
                    window.location.href = path + "/login.jsp"
                } else if (data == 0) {
                    alert("两次密码不正确")
                }

            },
            error: function (data) {
                alert("数据库没有此用户名")

            }
        })
    }

</script>
<div style="margin-left: 500px;margin-top: 200px ;line-height: 55px;border: 1px solid yellow;background-color: white;width: 600px; opacity: 0.8;height: 270px">
    <div style="width: 30% ;margin: 0px auto">
        <strong style="font-size: 40px">美食天下</strong>
    </div>

    <form style="width: 30% ;margin: 0px auto">
        <label style="position: absolute;left: 575px;font-size: 20px;position: absolute;top: 253px">新的登录密码</label>
        <input type="hidden" id="username" value="${sessionScope.user.username}">
        <input type="password" size="46" style="height: 30px; line-height: 50px;position: absolute;left: 720px;top: 270px" id="pass1" value=""><br>
        <label style="position: absolute;left: 535px;font-size: 20px;position: absolute;top: 328px">确认新的登录密码</label>
        <input type="password" size="46" style="height: 30px; line-height: 50px;position: absolute;left: 720px;top: 340px" id="pass2" value=""><br>
        <input type="hidden" id="path" value="<%=path%> " style="margin-left: 60px">

    </form>
    <button style="margin-left: 120px ;background-color: red;color: white;border-color: red;width: 100px;height: 35px;position: absolute;right: 487px;top: 400px"
            onclick="fun1()">确定
    </button>
</div>
</body>
</html>
